#ifndef NODESOCKET_H
#define NODESOCKET_H

enum POSITION{
    LEFT_TOP = 1,
    RIGHT_TOP = 2,
    LEFT_BOTTOM = 3,
    LEFT_RIGHT_BOTTOM = 4,

};
enum TYPE{
    SOCKET_INPUT = 0,
    SOCKET_OUTPUT = 1
};

enum DATATYPE{
    DATA_NUMBER = 0,
    DATA_IMAGE = 1,
    DATA_OTHER = 2
};


//enum EDGE_MODE{
//    EDGE_NOOP = 0,
//    EDGE_DRAG = 1

//};


#include<QGraphicsItem>
#include<QColor>
#include<QtGui>
#include<QDebug>
#include<QGraphicsSceneMouseEvent>
#include"item_enum.h"

class NodeSocket:public QGraphicsItem
{
public:
    NodeSocket(QGraphicsItem *parent = nullptr);
    NodeSocket(const NodeSocket &socket);
    ~NodeSocket();
    void operator=(const NodeSocket &socket);
    void SetIndex(int index);
    void SetType(enum TYPE type);
    void SetPosition();
    int type() const override {return Type_NodeSocket;}

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    QRectF boundingRect()const override;
    bool contains(const QPointF &point) const override;
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;


    enum TYPE socket_type;
    //enum EDGE_MODE edge_mode;
    int index;
    int node_index=-1;  // 连接上该socket的节点
    int out_socket_index =-1;   // 连接上该socket的节点的socket

    bool selected_index = false;
    bool isConnected = false;    // only input socket need

    // paint 相关
    float radius = 6.0;
    QColor *color_basic;  // socket 颜色  basic:number, image:image
    QColor *color_outline;
    QPen *pen;
    QBrush *brush;

private:
};

#endif // NODESOCKET_H
